package com.ssy.lingxi.product.controller.feign.price;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.ssy.lingxi.common.constant.Constants;
import com.ssy.lingxi.common.constant.product.CommodityStatusEnum;
import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.exception.BusinessException;
import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.ResponseCode;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.product.api.model.request.CommodityCreditScore;
import com.ssy.lingxi.product.api.model.request.CommoditySold;
import com.ssy.lingxi.product.api.model.request.MemberRequest;
import com.ssy.lingxi.product.api.model.request.SimpleIdListRequest;
import com.ssy.lingxi.product.api.model.request.channelCommodity.ChannelCommodityQueryRequest;
import com.ssy.lingxi.product.api.model.request.commodity.CommodityQueryRequest;
import com.ssy.lingxi.product.api.model.request.feign.CommodityNameRequest;
import com.ssy.lingxi.product.api.model.request.feign.CommodityPriceRequest;
import com.ssy.lingxi.product.api.model.request.feign.CommodityPublishRequest;
import com.ssy.lingxi.product.api.model.request.feign.OffPublishCommodityRequest;
import com.ssy.lingxi.product.api.model.request.price.ContractPriceRequest;
import com.ssy.lingxi.product.api.model.request.price.OrderPriceRequest;
import com.ssy.lingxi.product.api.model.response.BrandResponse;
import com.ssy.lingxi.product.api.model.response.channelCommodity.ChannelCommodityESResponse;
import com.ssy.lingxi.product.api.model.response.commodity.*;
import com.ssy.lingxi.product.api.model.response.feign.CommodityPriceResponse;
import com.ssy.lingxi.product.api.model.response.feign.CommoditySkuStockResponse;
import com.ssy.lingxi.product.api.model.response.store.StoreCommodityResponse;
import com.ssy.lingxi.product.api.model.response.store.StoreResponse;
import com.ssy.lingxi.product.entity.Brand;
import com.ssy.lingxi.product.entity.channelCommodity.ChannelCommodity;
import com.ssy.lingxi.product.entity.commodity.Commodity;
import com.ssy.lingxi.product.entity.commodity.CommodityGoodsAttribute;
import com.ssy.lingxi.product.entity.commodity.CommodityUnitPriceAndPic;
import com.ssy.lingxi.product.entity.customer.CustomerCategory;
import com.ssy.lingxi.product.service.IBrandService;
import com.ssy.lingxi.product.service.IChannelCommodityService;
import com.ssy.lingxi.product.service.ICommodityService;
import com.ssy.lingxi.product.service.IGoodsService;
import com.ssy.lingxi.product.service.customer.ICustomerCategoryService;
import com.ssy.lingxi.product.service.es.ISyncEsCommodityService;
import com.ssy.lingxi.product.service.price.IPriceManagementService;
import org.apache.commons.lang.StringUtils;
import org.modelmapper.TypeToken;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 物料信息管理内部接口
 * @author lxc
 * @version 2.0.0
 * @date 2022/4/2
 */
@RestController
@RequestMapping("/product/feign/goods")
public class GoodsPriceFeignController extends BaseController {

    @Resource
    private IPriceManagementService priceManagementService;

    /**
     * 合同物料信息同步更新
     * @param request 物料价格信息
     */
    @RequestMapping(value = "/price/contract/change", method = RequestMethod.POST)
    public Wrapper<Void> changeContractGoodsPrice(@RequestBody @Valid ContractPriceRequest request) {
        return priceManagementService.changeContractGoodsPrice(request);
    }

    /**
     * 订单物料信息同步更新
     * @param request 物料价格信息
     */
    @RequestMapping(value = "/price/order/change", method = RequestMethod.POST)
    public Wrapper<Void> changeOrderGoodsPrice(@RequestBody @Valid OrderPriceRequest request) {
        return priceManagementService.changeOrderGoodsPrice(request);
    }

}
